#include "poll.h"
#include "error.h"

#include <poll.h>
#include <type_traits>

namespace _ {

static_assert(std::is_same_v<Wrap::nfds_t_, nfds_t>, "nfds_t");

}


short Wrap::poll_in() {
    return POLLIN;
}

short Wrap::poll_pri() {
    return POLLPRI;
}

short Wrap::poll_out() {
    return POLLOUT;
}

short Wrap::poll_err() {
    return POLLERR;
}

short Wrap::poll_hup() {
    return POLLHUP;
}

short Wrap::poll_nval() {
    return POLLNVAL;
}

short Wrap::poll_remove() {
#ifdef POLLREMOVE
    return POLLREMOVE;
#else
    return 0;
#endif
}

short Wrap::poll_rdhup() {
#ifdef POLLRDHUP
    return POLLRDHUP;
#else
    return 0;
#endif
}

int Wrap::poll_(struct pollfd *fds, nfds_t_ nfds, int timeout) {
    return PERROR_NEG(::poll(fds, nfds, timeout));
}
